#Java - Code Snippets for '#Javax.net.ssl.TrustManager' - 3 code snippet(s) found |
|
Sample 1. Code Sample / Example / Snippet of javax.net.ssl.TrustManager | |
|
public SSLContextBuilder loadTrustMaterial(
final KeyStore truststore,
final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException {
final TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(
TrustManagerFactory.getDefaultAlgorithm());
tmfactory.init(truststore);
final TrustManager[] tms = tmfactory.getTrustManagers();
if (tms != null) {
if (trustStrategy != null) {
for (int i = 0; i < tms.length; i++) {
final TrustManager tm = tms[i];
if (tm instanceof X509TrustManager) {
tms[i] = new TrustManagerDelegate(
(X509TrustManager) tm, trustStrategy);
}
}
}
for (final TrustManager tm : tms) {
this.trustmanagers.add(tm);
}
}
return this;
}
|
|
Like Feedback javax.net.ssl.TrustManager |
|
|
Sample 2. Code Sample / Example / Snippet of javax.net.ssl.TrustManagerFactory | |
|
public SSLContextBuilder loadTrustMaterial(
final KeyStore truststore,
final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException {
final TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(
TrustManagerFactory.getDefaultAlgorithm());
tmfactory.init(truststore);
final TrustManager[] tms = tmfactory.getTrustManagers();
if (tms != null) {
if (trustStrategy != null) {
for (int i = 0; i < tms.length; i++) {
final TrustManager tm = tms[i];
if (tm instanceof X509TrustManager) {
tms[i] = new TrustManagerDelegate(
(X509TrustManager) tm, trustStrategy);
}
}
}
for (final TrustManager tm : tms) {
this.trustmanagers.add(tm);
}
}
return this;
}
|
|
Like Feedback javax.net.ssl.TrustManagerFactory |
|
|
Sample 3. Code Sample / Example / Snippet of javax.net.ssl.TrustManagerFactory | |
|
private TrustManager[] getTrustManagerFactory(String truststoreFile, String storePass) throws IOException, GeneralSecurityException {
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
InputStream is = null;
try {
is = new FileInputStream(truststoreFile);
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(is, storePass.toCharArray());
tmf.init(ks);
return tmf.getTrustManagers();
}
finally {
try {
if (is != null) {
is.close();
}
}
catch (IOException e) {
}
}
}
|
|
Like Feedback javax.net.ssl.TrustManagerFactory |
|
|